import { ref, onMounted } from "vue";
import { queryHomePage } from "@/api/routes";

export function useWelcome() {
  const produceQuestionSize = ref(0);
  const simulatorQuestionSize = ref(0);
  const producePaperSize = ref(0);
  const produceTaskSize = ref(0);
  const studentXtUserSize = ref(0);

  async function onQueryHome() {
    queryHomePage().then(res => {
      if (res.success) {
        produceQuestionSize.value = res.produceQuestionSize;
        simulatorQuestionSize.value = res.simulatorQuestionSize;
        producePaperSize.value = res.producePaperSize;
        produceTaskSize.value = res.produceTaskSize;
        studentXtUserSize.value = res.studentXtUserSize;
      }
    });
  }

  onMounted(() => {
    onQueryHome();
  });

  return {
    produceQuestionSize,
    simulatorQuestionSize,
    producePaperSize,
    produceTaskSize,
    studentXtUserSize
  };
}
